home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 20 / Cream of the Crop 20 (Terry Blount) (1996).iso / program / n_b_v203.zip / DAC.TXT < prev    next >
Text File  |  1996-07-04  |  7KB  |  135 lines

  1. $if 0
  2.     ┌──────────────────────────╖                        PowerBASIC v3.20
  3.  ┌──┤          DASoft          ╟──────────────────────┬──────────────────╖
  4.  │  ├──────────────────────────╢    Copyright 1995    │ DATE: 1995-10-01 ╟─╖
  5.  │  │ FILE NAME   DAC     .TXT ║          by          ╘════════════════─ ║ ║
  6.  │  │                          ║  Don Schullian, Jr.                     ║ ║
  7.  │  ╘══════════════════════════╝                                         ║ ║
  8.  │ A license is hereby granted to the holder to use this source code in  ║ ║
  9.  │ any program, commercial or otherwise,  without receiving the express  ║ ║
  10.  │ permission of the copyright holder and without paying any royalties,  ║ ║
  11.  │ as long as this code is not distributed in any compilable format.     ║ ║
  12.  │  IE: source code files, PowerBASIC Unit files, and printed listings   ║ ║
  13.  ╘═╤═════════════════════════════════════════════════════════════════════╝ ║
  14.    │                ....................................                   ║
  15.    ╘═══════════════════════════════════════════════════════════════════════╝
  16. $endif
  17.  
  18. So, you say you don't really like the 16 beautiful, hand-picked colors
  19. you find on your VGA screen! Well, let's fix that. You have 262,144 to
  20. choose from. Of course you can only access 16 at a time,  but at least
  21. you now have a choice.
  22.  
  23. Each color you see on your screen is a presence of or absence of one or
  24. more of the 3 colors, Red, Green, or Blue.  Each RGB color value can be
  25. from 0 ( none ) to 63 ( full ).  If you have a color that is made up of
  26. 63 Red, 0 Green, and 0 Blue then what you see is a very bright pure red
  27. If you have 08R, 08G, 08B then you get what you normally know as DkGrey
  28. or color 8 and, of course 0, 0, 0 is Black! So, the lower the RGB value
  29. the darker the color and  the higher the RGB number the brighter it is.
  30.  
  31. There are 256 colors or positions in the DAC, and each holds a RGB value.
  32. SCREEN 0 and SCREEN 12 can only access the first 64 of these and they are
  33. what need to be changed in order for PowerBASIC to display all the colors
  34. available.
  35.  
  36. Now, we are going to run into some trouble with names here, so:
  37.   PALETTE is PowerBASIC's palette number which holds a DAC number
  38.   DAC     is DOS's palette number which holds the RGB values
  39.  
  40. Think of it like this:
  41.   PowerBASIC has an array with 16 elements      ( 0 -> 15 )
  42.   Each element holds a DAC number               ( 0 -> 63 )
  43.   PALETTE sets the element(s) to the DAC number
  44.  
  45. Ok, one more time.......
  46.    When you use the COLOR statement it points to
  47.       one of the 16 PALETTE numbers which points to
  48.       one of the 64 available DAC numbers which hold the
  49.       R, G, and B values.
  50.  
  51.    So..............
  52.       You change the DAC's RGB values in position 62 to 23,00,26
  53.       then tell PALETTE 62, 15 so when you do a COLOR 14,15
  54.       what you get are yellow letters on a purple background
  55.  
  56. EXAMPLE: CALL DACset( 62, 23, 00, 26 )
  57.          PALETTE 62, 15
  58.          COLOR 14, 15
  59.          CLS
  60.          PRINT "YELLOW LETTERS ON A PURPLE BACKGROUND"
  61.  
  62. As the DAC is laid out in one long string of BYTE values we use STRINGs
  63. and BYTE arrays to interface with it.
  64.  
  65. POSs  000 001 002 003 004 005 006 007 008 009 010 011 012 013 014 015
  66.      ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬
  67. VALs │RGB│RGB│RGB│RGB│RGB│RGB│RGB│RGB│RGB│RGB│RGB│RGB│RGB│RGB│RGB│RGB│R
  68.      └───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴──
  69.  
  70. To address the first 16 DAC positions you could dim an array in either of
  71. these 2 ways.  I prefer the 1st example as it allows me to quickly access
  72. the individual RGB values "by the numbers".
  73.  
  74. DIM DACvals?( 0:2, 0:15 )   is a handy way or
  75. DIM DACvals?( 1:48 )        will work just as well
  76. DIM DACvals?( 0:2, 0:255 )  will get them all!!!
  77.  
  78. Everything you need to do all of this is either part of PowerBASIC or
  79. can be found in this library; there's a raft of ready-to-go colors to
  80. get you started.
  81.  
  82. If you want to do 3D images then you've got to put up with a few more
  83. restrictions because you only have 16 colors to work with and to do 3D
  84. you need 3 variations of each color (except the background) so you are
  85. reduced to 5 normal colors, 5 light colors, and 5 dark colors. But you
  86. will be surprized at just how effective it is when used in graphics!
  87.  
  88. As you browse through the list of ready-to-go colors in DACdata you'll
  89. notice that I have prepared color sets to get  you started on your own
  90. 3D VGA screens.  To draw a box who's light source is in the upper left
  91. corner of the screen you would draw the  top and left borders with the
  92. light color,  the bottom and right borders with the dark color  and the
  93. box itself would be in the normal color. This would make the box appear
  94. to pop-out of the screen! The trick is arranging your colors as we have
  95. in the test program.
  96.  
  97. Ok, just a quick art lesson here:
  98.    There are 3 true colors:  RED, BLUE, YELLOW
  99.    There are 6 primaries  :  RED, PURPLE, BLUE, GREEN, YELLOW, ORANGE
  100.    PURPLE = RED    & BLUE
  101.    GREEN  = BLUE   & YELLOW
  102.    ORANGE = YELLOW & RED
  103.    BLACK  = ABSENCE OF ALL COLOR    ( Night time, no sun )
  104.    WHITE  = IS THE EQUAL PRESENCE OF ALL 3
  105.    GREY   = PRESENCE OF ALL 3 IN UNEQUAL PROPORTIONS
  106.  
  107.    Each color has a "feel":  BLUE   = Cool, calming
  108.                              YELLOW = Warm, full of life
  109.                              RED    = Hot!, danger, etc.
  110.  
  111.    On the computer each of the 3 colors RED, GREEN, BLUE can have a value
  112.    of 0 -> 63. The higher the number the "brighter" the color. Each is
  113.    effected by the other. Yellow is true color and only exists on the box
  114.    as a part of GREEN so to get yellow you have to pump in the green then
  115.    use RED to cancel the blue. ??? say what!? Yea, really neat, huh?
  116.  
  117.    Try to remember these simple rules when designing your programs as
  118.    the colors you use/mix are much more important than you think! To exude
  119.    calm and peace stick to blues and yellows. Go light on the reds. Colors
  120.    effect each other also, don't mix purple and yellow unless you want to
  121.    make someone jump out of his/her skin. Ditto with green and orange.
  122.    Pastels are soft and sleepy. Premieres are REAL good for young children.
  123.    Go forth, now and make Picasso jealous!
  124.  
  125. That's about as far as we can carry this discussion here.  Other .PBLs
  126. deal with graphic screen and we go into more detail at that time. This
  127. library is just a NUTZnBOLTS unit and not able to deal with it all!
  128.  
  129. Ahhhhhhhh... just a thought.... there are 64 DAC locations and PB uses
  130. 16DAC locations at a shot and 64\16 = 4 and DIM DAC?( 3, 2, 15 ) gives
  131. a total of 64 * 3 holes.....   Good luck & have some fun with these as
  132. they really perk up your programs and make them stand-out from all the
  133. rest, even in TEXT MODE!!
  134.  
  135.